package com.kou.backend.exception;

import com.kou.backend.error.ICommonError;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 通用标准异常
 *
 * @author: Kou
 * @since: 2023/8/26 19:56
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class CommonException extends RuntimeException implements ICommonError {
    private String errorCode;
    private String errorMsg;

    public CommonException(String errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public CommonException(ICommonError iCommonError) {
        super(iCommonError.getErrorMsg());
        this.errorCode = iCommonError.getErrorCode();
        this.errorMsg = iCommonError.getErrorMsg();
    }
}
